package it.uni.bo.monitoring.protocol.unmarshaller.analysis;
import it.uni.bo.monitoring.protocol.server.DataObject;
import it.uni.bo.monitoring.protocol.unmarshaller.EventInfo;

import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;


public class DataAnalysis{


	private ArrayList<Validation> vl;
	private Logger l;

	public DataAnalysis(SessionFactory factory){
		l = Logger.getLogger(this.getClass());	
		vl = new ArrayList<Validation>();
		Validation v1= 	new SizeControl();
		Validation v2= new SemanticControl(factory);
		Validation v3= new ParametersControl(factory);
		Validation v4= new StateControl(factory);
		vl.add(v1);
		vl.add(v2);
		vl.add(v3);
		vl.add(v4);
	}

	public EventInfo analyse(DataObject rdo) {
		EventInfo ei=new EventInfo(rdo);		

		for(int i=0;i<vl.size();i++){
			if(!vl.get(i).validate(ei)){
				return null;
			}
		}
		return ei;
	} 
	
	
}
